<?php
namespace app\system\controller;

use dingtalk\Auth;
use think\Controller;
use think\Cookie;
use think\Request;

class BaseController extends Controller
{
    private $accessToken;
    private $jsTicket;
    private $dingtalkConfig;
    private $dduser;
    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        if(Cookie::has('user')){
            $this->dduser = Cookie::get('user');
        }else{
            //$this->redirect('Public/auth');
        }
        $this->accessToken=Auth::getAccessToken();
        $this->jsTicket=Auth::getTicket($this->accessToken);
        $this->dingtalkConfig = Auth::getConfig();
        $this->assign('dduser',$this->dduser);
        $this->assign('auth_config',$this->dingtalkConfig);
    }

    /**
     * 获取用户信息
     * @return mixed
     */
    public function dduser(){
        return $this->dduser;
    }

    /**
     * 获取accessToken
     * @return mixed
     */
    public function getAccessToken(){
        return $this->accessToken;
    }

    /**
     * 获取JsTicket
     * @return mixed
     */
    public function getJsTicket(){
        return $this->jsTicket;
    }

    /**
     * 获取钉钉配置参数
     * @return string
     */
    public function getddConfig(){
        return $this->dingtalkConfig;
    }


}
